package com.qingyu.print.order.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author qingyu
 * @create 20210814:25
 */
public final class OrderNumUtil {

    public static String getOrderNum(){
        String num = getTime().replaceAll("[[\\s-:punct:]]", "")+getRandomNum();
        System.out.println("订单编号为----->" + num);
        return num;
    }

    public static String getTime() {
        SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("时间戳："+sdfTime.format(new Date()));
        return sdfTime.format(new Date());
    }

    public static int getRandomNum(){
        Random r = new Random();
        return r.nextInt(900000)+100000;//(int)(Math.random()*999999)
    }





}
